// 方式一
// 时间：84ms - 55.21%
var generate = function(rowIndex) {
  let ret = [];
  let prev = [];
  for (let index = 0; index < rowIndex + 1; index++) {
    prev = ret;
    ret = generated(prev);
  }
  return ret;
  function generated(array) {
    const ret = [1];
    for (let index = 0; index < array.length; index++) {
      const current = array[index];
      const next = array[index + 1] || 0;
      ret.push(current + next);
    }
    return ret;
  }
};
console.log(generate(3));
